import { Component, OnInit, Input } from '@angular/core';
import { LocalStorageService } from 'src/app/myService/local-storage.service';
import { Router } from '@angular/router';
import { AxiosService } from '../../axios.service';
import { ActivatedRoute } from '@angular/router';
import { data } from 'jquery';
import { DatePipe } from '@angular/common';
import { copyFileSync } from 'fs';
import CONFIG from '../../../assets/config/config.json'

@Component({
  selector: 'app-cnc',
  templateUrl: './cnc.component.html',
  styleUrls: ['./cnc.component.scss'],
  providers: [DatePipe]

})
export class CNCComponent implements OnInit {

  today: any = new Date();
  public date = new Date();
  public dateDay = this.date.getDay();
  public milliSeconds = this.date.getMilliseconds();
  public weeks = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六");
  public week = this.weeks[this.dateDay];
  public link; //下载链接
  imglist;

  showTime: any = new Date();
  public year = this.showTime.getFullYear();
  public mon = this.showTime.getMonth() + 1;
  public da = this.showTime.getDate();
  public hour = this.showTime.getHours();
  public munite = this.showTime.getMinutes();
  public second = this.showTime.getSeconds();
  public day = this.year + '-' + this.mon + '-' + this.da + ' ' + this.hour + ':' + this.munite + ':' + this.second;
  banBie = ""; //班别
  time;
  showInfom; //是否显示表头之前的信息
  userInfo: any;
  name;
  name_PY;
  job_no;
  department;
  department_abb;
  role;
  password;
  CNCdata;  //接受跳转页面的union_order
  CNCname; // 接受跳转页面的机台名
  id; //接受CNC的id编号
  union_order = '';
  zjmc = ''; // 治具名称
  factory = ''; // 厂别
  ljmc = ''; // 零件名称
  cxmc = '';
  tdgd = '';
  ygsj = '';
  material_no = '';
  czhi = '';
  tzcc = '';
  djxq = '';
  zjfs = '';
  jgyd = '';
  // djqr = '';
  // jcqj = '';
  // dpdw = '';
  // mcqj = '';
  // cxycclsj = '';
  dbjz = '';
  zjbs = '';
  zjzgs;
  cnc = '';
  cncsj = '';
  box = '';
  xlcc_x = '';
  xlcc_y = '';
  xlcc_z = '';
  xlcc_bs = '';
  xlcc_pb = '';
  yjjg = '';
  gjsl = '';
  blps = '';
  bcry = '';
  bzhu = '';
  arr = []; //接受所有的ljmc
  isVisible = false;
  listOfData = []; //表单数组
  tablePageList = [];  //分页后前台显示数据
  pageNo = 1; //总页数
  preShow = false; //上一页
  nextShow = true; //下一页
  pageSize = 9; //单页显示数
  curPage = 1; //当前页
  isShow = false;
  searchValue = ''; //筛选框输入的内容
  listOfDisplayData = []; //筛选
  url;
  newurl;
  editCache = {}; //修改排工单信息
  checked = false; //是否选择拼版
  isdisplay = false; //是否显示'分钟'和'号'
  workerName; //工件名
  //其他备注
  addOtherRemark;
  style = {
    display: 'block',
    height: '35px',
    width: '130px',
    lineHeight: '35px',
    padding: '0px 15px'
  };
  isOkLoadingOthRemark;
  RemarkValue; //备注框的值
  workKey;
  showWarning = {}; //工件行显示退回图标
  showBigWarning; //工单行显示退回图标
  sheet_order; //
  Remark; //上一页返回的退单备注
  wz;//哪里来的
  statuswz;//哪里来改为状态
  isSendVisible = false;
  oneauto = 0;
  fdnumber;
  // fdbox;
  fdcnc;
  fdmaxnumber;
  isSendOkLoading;
  isOkLoadingfileInfom;
  zjfsArr = [];
  jgydArr = ['第一象限', '第二象限', '第三象限', '第四象限', '四面分中'];
  zjfsTime = [];
  isVisible2;
  fdcnclist = ["所有機台"];
  fdid;
  readybye;
  fileInfom2 = false;
  deliveryName = CONFIG['deliveryName'];

  constructor(
    private storage: LocalStorageService,
    private router: Router,
    public axios: AxiosService,
    public activatedRoute: ActivatedRoute,
    private datePipe: DatePipe,

  ) {
  }

  ngOnInit(): void {
    // //判断路由
    // this.url = window.location.href;
    // this.newurl = this.url.split("$");
    // if (this.newurl.length <= 3){
    //   this.url += "$1$2$3$2";
    //   window.location.href = this.url;
    // }
    // 修改头部与左侧高度

    var n = new Date().getFullYear();
    var y = (new Date().getMonth() + 1).toString();
    y = Number(y) < 10 ? ("0" + y) : y;
    var r = new Date().getDate().toString();
    r = Number(r) < 10 ? ("0" + r) : r;

    var sj = n + "-" + y + "-" + r;
    console.log(sj)
    this.axios.axiosPost("QueryCncInfo", { "status": "cncTime", starttime: sj }).then((data) => {
      console.log(data)
      for (var i = 0; i < data["order"].length; i++) {
        this.fdcnclist.push(data["order"][i].name)
      }
      console.log(this.fdcnclist)
    })
    document.getElementsByClassName("ant-layout-header")[0].setAttribute('style', 'line-height:21px;padding:0 20px !important;');
    this.userInfo = this.storage.getStorageData('user');
    console.log('--------------------\n', this.userInfo)
    this.name = this.userInfo.name;
    this.name_PY = this.userInfo.name_PY;
    this.job_no = this.userInfo.job_no;
    this.department = this.userInfo.department;
    this.department_abb = this.userInfo.department_abb;
    this.role = this.userInfo.role;
    this.password = this.userInfo.password;

    // 获取上一页面跳转过来的工单号
    this.activatedRoute.params.subscribe((data) => {
      this.CNCdata = data['union_order'];
      console.log(data)
      console.log(this.Remark)
      console.log(this.CNCdata);
    });

    // 获取上一页面跳转过来的机台号
    this.activatedRoute.params.subscribe((CNCnum: any) => {
      // debugger
      if (CNCnum['select']) {
        this.CNCname = CNCnum['select'];
        console.log(CNCnum['select']);

      } else {
        this.CNCname = "所有機台"
        console.log("触发");

      }
      this.wz = CNCnum["from"];

      this.showInfom = true;
      this.time = this.year + '-' + this.mon + '-' + this.da;
      // this.banBie = this.day.split(' ')[1];
      // console.log(this.day)
      // const timeCount = parseInt(this.day.split(' ')[1].split(':')[0]) * 3600 + parseInt(this.day.split(' ')[1].split(':')[1]) * 60 + parseInt(this.day.split(' ')[1].split(':')[2]);
      // console.log(this.banBie, timeCount)
      // if (timeCount > 28800 && timeCount < 72000) {
      //   this.time = this.day.split(' ')[0];
      //   // this.banBie = '白班';
      // } else if (timeCount > 72000 && timeCount < 86400) {
      //   this.time = this.day.split(' ')[0];
      //   // this.banBie = '晚班';
      // } else {
      //   var year = this.showTime.getFullYear();
      //   var mon = this.showTime.getMonth() + 1;
      //   var da = this.showTime.getDate() - 1;

      //   var date = year + '-' + mon + '-' + da;
      //   this.time = date;
      //   // this.banBie = '晚班';
      // }
      console.log(this.CNCname, this.time, this.banBie);
    })

    // 获取CNC工单信息
    this.allUnion();
    this.getjgfsData();
  }

  // 注销返回login
  cancel() {
    this.name = this.userInfo.job_no;
    const data = {};
    data['name'] = this.name;
    this.storage.removeAllStorageData();
    this.router.navigate(['/login', data])
  }

  EndChange(date: Date): void {
    this.time = date;
    this.time = this.datePipe.transform(this.time, 'yyyy-MM-dd');
    console.log("修改就触发")
    console.log(this.time)
    this.allUnion()
  }

  // 返回上一页面
  back() {
    history.go(-1);
  }

  getjgfsData() {
    this.axios.axiosPost('QueryZhuangjiaInfo')
      .then((data) => {
        if (data) {
          console.log(data);
          this.zjfsTime = data['order']
          for (let i = 0; i < this.zjfsTime.length; i++) {
            this.zjfsArr.push(this.zjfsTime[i].mode);
          }
          console.log(this.zjfsArr);
        }
      })
      .catch((err) => {
        console.log(err);
      });
  }

  provinceChange(value: string, key): void {
    console.log(value, this.zjfsTime);
    console.log(key)
    for (let i = 0; i < this.zjfsTime.length; i++) {
      if (value == this.zjfsTime[i].mode) {
        // this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].djqr = this.zjfsTime[i].time[0]['value'];
        // this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].jcqj = this.zjfsTime[i].time[1]['value'];
        // this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].dpdw = this.zjfsTime[i].time[2]['value'];
        // this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].mcqj = this.zjfsTime[i].time[3]['value'];
        // this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].cxycclsj = this.zjfsTime[i].time[4]['value'];
        this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].dbjz = this.zjfsTime[i].time[0]['value'];
      }
    }
    // console.log(this.djqr);
  }

  provinceChange1(value: string): void {
    console.log(value, this.zjfsTime);
    for (let i = 0; i < this.zjfsTime.length; i++) {
      if (value == this.zjfsTime[i].mode) {
        // this.djqr = this.zjfsTime[i].time[0]['value'];
        // this.jcqj = this.zjfsTime[i].time[1]['value'];
        // this.dpdw = this.zjfsTime[i].time[2]['value'];
        // this.mcqj = this.zjfsTime[i].time[3]['value'];
        // this.cxycclsj = this.zjfsTime[i].time[4]['value'];
        this.dbjz = this.zjfsTime[i].time[0]['value'];
      }
    }
  }

  // 获取排工单信息
  allUnion() {
    let a;
    // 判断来自 加工或者编程  为空显示所有
    if (this.wz == "jg") {
      this.statuswz = 2;
    } else if (this.wz == "bc") {
      this.statuswz = 1;
    } else {
      this.statuswz = ""
    }
    //  没有指定机台  则显示所有机台
    if (!this.CNCname || this.CNCname == "所有機台") {
      this.CNCname = "所有機台";
      a = "";
    } else {
      a = this.CNCname;
      this.CNCname = this.CNCname
    }
    console.log("来自1是编程2是加工:" + this.statuswz)
    // 有机台号
    // debugger
    // 点击某个机台进入
    console.log("请求的班别是:" + this.banBie)
    console.log("机台名称:" + this.CNCname)
    if (this.statuswz == 1 && this.oneauto == 0) {
      this.banBie = ""
      this.oneauto++;
    }

    this.axios.axiosPost('QueryCncData', { 'unionorder': this.CNCdata, "banci": this.banBie, "status": this.statuswz, "riqi": this.time, 'cnc': a })
      .then((data) => {
        if (data['result'] === 'ok') {
          console.log(data)
          this.listOfData = data['order'];
          this.listOfDisplayData = [...this.listOfData];
          this.getPageList();
          // this.zjzgs = [];
          // debugger
          for (let i = 0; i < this.listOfData.length; i++) {
            this.editCache[i] = { edit: false, isdel: false, data: this.listOfData };
          }
          console.log(this.listOfData)
          this.storage.setStorageData('result', this.listOfData);
        }
      })
      .catch((err) => {
        console.log(err);
      })
  }

  getPageList() {
    console.log(this.listOfData)
    // debugger
    if (this.listOfData.length >= 1) {
      if (this.listOfData.length % this.pageSize === 0) {
        this.pageNo = Math.floor(this.listOfData.length / this.pageSize);
      } else {
        this.pageNo = Math.floor(this.listOfData.length / this.pageSize) + 1;
      }
      if (this.pageNo < this.curPage) {
        this.curPage = this.curPage - 1;
      }
      if (this.pageNo === 1 || this.curPage === this.pageNo) {
        this.preShow = this.curPage !== 1;
        this.nextShow = false;
      } else {
        this.preShow = this.curPage !== 1;
        this.nextShow = true;
      }
    } else {
      this.listOfData.length = 0;
      this.pageNo = 1;
      this.curPage = 1;
    }
    this.tablePageList = this.listOfData.slice((this.curPage - 1) * this.pageSize, (this.curPage) * this.pageSize);
    console.log(this.tablePageList)
    const data = this.tablePageList;

  }
  //点击上一页方法
  showPrePage() {
    this.curPage--;
    if (this.curPage >= 1) {
      this.getPageList();
    } else {
      this.curPage = 1;
    }
  }
  //点击下一页方法
  showNextPage() {
    this.curPage++;
    if (this.curPage <= this.pageNo) {
      this.getPageList();
    } else {
      this.curPage = this.pageNo;
    }
  }
  //自定义跳页方法
  onChangePage(value) {
    if (value > this.pageNo) {
      confirm('超出最大页数');
    } else if (value <= 0) {
      this.curPage = 1;
      this.getPageList();
    } else {
      this.curPage = value;
      this.getPageList();
    }
  }
  //改变每页显示方法
  onChangePageSize(value) {
    this.pageSize = value;
    this.curPage = 1;
    this.getPageList();
    console.log(this.listOfData)
  }

  // 添加数据
  // 新增空input
  showinput() {
    this.isShow = true;
    this.union_order = '';
    this.zjmc = '';
    this.factory = '';
    this.ljmc = '';
    this.cxmc = '';
    this.tdgd = '';
    this.ygsj = '';
    this.material_no = '';
    this.czhi = '';
    this.tzcc = '';
    this.djxq = '';
    this.zjfs = '';
    this.jgyd = '';
    // this.djqr = '';
    // this.jcqj = '';
    // this.dpdw = '';
    // this.mcqj = '';
    // this.cxycclsj = '';
    this.dbjz = '';
    this.zjbs = '';
    this.cnc = '';
    this.cncsj = '';
    this.box = '';
    this.xlcc_x = '';
    this.xlcc_y = '';
    this.xlcc_z = '';
    this.xlcc_bs = '';
    this.checked = false;
    this.yjjg = '';
    this.gjsl = '';
    this.blps = '';
    this.bcry = '';
    this.bzhu = '';
    // this.zjzgs = '';
  }

  // 读取db中工单号的相关信息到input中
  pushCNC() {
    for (let i = 0; i < this.listOfData.length; i++) {
      if (this.ljmc === this.listOfData[i]['ljmc']) {
        this.union_order = this.listOfData[i]['union_order'];
        this.zjmc = this.listOfData[i]['name'];
        this.factory = this.listOfData[i]['factory'];
        this.czhi = this.listOfData[i]['czhi'];
        this.tzcc = this.listOfData[i]['tzcc'];
        this.cnc = this.listOfData[i]['cnc'];
        this.box = this.listOfData[i]['box'];
        this.material_no = this.listOfData[i]["material_no"];
        // this.zjzgs = '';
      }
    }
    console.log(this.zjzgs)
  }

  // 确认添加
  confirmAdd() {
    console.log(this.cnc)
    if (this.checked == true) {
      this.xlcc_pb = '√'
    } else if (this.checked == false) {
      this.xlcc_pb = ''
    }
    console.log(this.checked)
    // 计算装夹总工时
    // let djqr = this.djqr;
    // let jcqj = this.jcqj;
    // let dpdw = this.dpdw;
    // let mcqj = this.mcqj;
    // let cxycclsj = this.cxycclsj;
    let dbjz = this.dbjz;
    let zjbs = this.zjbs;
    // let zjzgs = Number(djqr) + Number(jcqj) + Number(dpdw) + Number(mcqj) + Number(cxycclsj) + Number(dbjz) * Number(zjbs);
    let zjzgs = Number(dbjz) * Number(zjbs);
    this.zjzgs = zjzgs;
    // debugger
    this.axios.axiosPost('AddCncData', {
      'unionorder': this.union_order,
      'name': this.zjmc,
      'factory': this.factory,
      'ljmc': this.ljmc,
      'cxmc': this.cxmc,
      'tdgd': this.tdgd,
      'ygsj': this.ygsj,
      'material_no': this.material_no,
      'czhi': this.czhi,
      'tzcc': this.tzcc,
      'djxq': this.djxq,
      'zjfs': this.zjfs,
      'jgyd': this.jgyd,
      'dbjz': this.dbjz,
      'zjbs': this.zjbs,
      'cnc': this.cnc,
      'cncsj': this.cncsj,
      'box': this.box,
      'xlcc_x': this.xlcc_x,
      'xlcc_y': this.xlcc_y,
      'xlcc_z': this.xlcc_z,
      'xlcc_bs': this.xlcc_bs,
      'xlcc_pb': this.xlcc_pb,
      'yjjg': this.yjjg,
      'gjsl': this.gjsl,
      'blps': this.blps,
      'bcry': this.bcry,
      'bzhu': this.bzhu,
      'zjzgs': this.zjzgs,
      "jiagongriqi": this.time,
      "status": 1
    })
      .then((data) => {
        console.log(data)
        if (data['result'] === 'ok') {
          this.allUnion();
        }
      })
      .catch((err) => {
        console.log(err);
      })
    console.log(this.cnc)
    console.log(this.box)
    this.isShow = false;
  }

  // 取消添加
  cancelAdd() {
    this.isShow = false;
  }

  // 筛选的取消按钮
  reset(): void {
    this.searchValue = '';
    this.search();
  }
  // 筛选的确认搜索按钮
  search(): void {
    console.log(this.searchValue)
    const filterFunc = (item: { box: string; }) => {
      return (
        item.box.indexOf(this.searchValue) !== -1
      );
    };
    const data = this.listOfData.filter((item: { box: string; }) => filterFunc(item));
    this.listOfDisplayData = data;
    this.tablePageList = this.listOfDisplayData
    console.log(this.listOfDisplayData)
  }

  // 删除CNC
  handleOk() {
    this.isVisible = false;
    // debugger
    this.axios.axiosPost('DeleteCncData', { 'id': this.id })
      .then((data) => {
        console.log(data)
        if (data['result'] === 'ok') {
          this.allUnion();
        } else {
          alert('原始数据不可删除')
        }
      })
  }
  showModal(data): void {
    this.id = data.id
    console.log(this.id)
    this.isVisible = true;
  }
  handleCancel(): void {
    console.log('Button cancel clicked!');
    this.isVisible = false;
  }

  // 编辑 table转成input
  startEdit(key: number, data): void {
    console.log(key)
    console.log(data)
    this.editCache[key].isdel = true;
    this.editCache[key].edit = true;
    // console.log(this.pageNo);
    // console.log(this.pageSize);
    // console.log(this.editCache[key+(this.pageNo-1)*this.pageSize]);
    // this.editCache[key + (this.pageNo - 1) * this.pageSize].data[key + (this.pageNo - 1) * this.pageSize].union_order = data.union_order;
    // console.log(this.editCache[key + (this.pageNo - 1) * this.pageSize].data[key + (this.pageNo - 1) * this.pageSize].union_order)
    // if (this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].xlcc_pb == '√') {
    //   this.checked = true
    // } else {
    //   this.checked = false;
    // }

    this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].union_order = data.union_order;
    console.log(this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].union_order)
    if (this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].xlcc_pb == '√') {
      this.checked = true
    } else {
      this.checked = false;
    }
  }
  // 撤销修改
  cancelEdit(key: number): void {
    this.allUnion();
  }
  // 确认修改
  saveEdit(key: number): void {
    // debugger
    this.editCache[key].isdel = false;
    this.editCache[key].edit = false;
    // const index = this.listOfData.findIndex((item, index) => index === key);
    // Object.assign(this.listOfData[index], this.editCache[key].data);
    // 图纸尺寸
    const tzX = this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].tzcc.split('*')[0];
    const tzY = this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].tzcc.split('*')[1];
    const bangcai = this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].tzcc.substr(0, 1);
    console.log(bangcai);
    // 计算装夹总工时
    let djqr = this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].djqr;
    let jcqj = this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].jcqj;
    let dpdw = this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].dpdw;
    let mcqj = this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].mcqj;
    let cxycclsj = this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].cxycclsj;
    let dbjz = this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].dbjz;
    let zjbs = this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].zjbs;
    // let zjzgs = Number(djqr) + Number(jcqj) + Number(dpdw) + Number(mcqj) + Number(cxycclsj) + Number(dbjz) * Number(zjbs);
    let zjzgs = Number(dbjz) * Number(zjbs);
    this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].zjzgs = zjzgs;
    console.log(this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].zjzgs)
    // 棒材不做任何限制
    if (bangcai == 'D' && this.checked == false) {
      this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].xlcc_pb = '';
      this.axios.axiosPost('UpdateCncData', {
        'id': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].id,
        'cxmc': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].cxmc,
        'tdgd': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].tdgd,
        'ygsj': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].ygsj,
        'djxq': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].djxq,
        'zjfs': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].zjfs,
        'jgyd': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].jgyd,
        // 'djqr': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].djqr,
        // 'jcqj': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].jcqj,
        // 'dpdw': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].dpdw,
        // 'mcqj': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].mcqj,
        // 'cxycclsj': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].cxycclsj,
        'dbjz': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].dbjz,
        'zjbs': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].zjbs,
        'cnc': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].cnc,
        'cncsj': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].cncsj,
        'box': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].box,
        'xlcc_x': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].xlcc_x,
        'xlcc_y': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].xlcc_y,
        'xlcc_z': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].xlcc_z,
        'xlcc_bs': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].xlcc_bs,
        'xlcc_pb': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].xlcc_pb,
        'yjjg': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].yjjg,
        'gjsl': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].gjsl,
        'blps': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].blps,
        'bcry': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].bcry,
        'bzhu': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].bzhu,
        'zjzgs': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].zjzgs
      })
        .then((data) => {
          if (data['result'] === 'ok') {
            this.allUnion();
          }
        })
        .catch((err) => {
          console.log(err);
        })
    } else {
      // 拼板 下料尺寸>=图纸尺寸
      if (this.checked == true) {
        console.log(this.checked);
        this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].xlcc_pb = '√';
        if (Number(this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].xlcc_x) >= Number(tzX) && Number(this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].xlcc_y) >= Number(tzY)) {
          this.axios.axiosPost('UpdateCncData', {
            'id': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].id,
            'cxmc': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].cxmc,
            'tdgd': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].tdgd,
            'ygsj': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].ygsj,
            'djxq': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].djxq,
            'zjfs': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].zjfs,
            'jgyd': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].jgyd,
            // 'djqr': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].djqr,
            // 'jcqj': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].jcqj,
            // 'dpdw': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].dpdw,
            // 'mcqj': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].mcqj,
            // 'cxycclsj': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].cxycclsj,
            'dbjz': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].dbjz,
            'zjbs': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].zjbs,
            'cnc': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].cnc,
            'cncsj': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].cncsj,
            'box': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].box,
            'xlcc_x': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].xlcc_x,
            'xlcc_y': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].xlcc_y,
            'xlcc_z': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].xlcc_z,
            'xlcc_bs': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].xlcc_bs,
            'xlcc_pb': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].xlcc_pb,
            'yjjg': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].yjjg,
            'gjsl': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].gjsl,
            'blps': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].blps,
            'bcry': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].bcry,
            'bzhu': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].bzhu,
            'zjzgs': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].zjzgs
          })
            .then((data) => {
              if (data['result'] === 'ok') {
                this.allUnion();
              }
            })
            .catch((err) => {
              console.log(err);
            })
        } else {
          alert('下料尺寸不能小於圖紙尺寸');
          this.editCache[key].edit = true;
          this.editCache[key].isdel = true;
        }
      } else {
        // 不拼板 下料尺寸<=图纸尺寸+100  下料X + 下料Y <= tzX + tzY +100
        console.log(this.checked);
        this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].xlcc_pb = '';
        if (Number(this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].xlcc_x) >= Number(tzX)
          && Number(this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].xlcc_y) >= Number(tzY)
          && Number(this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].xlcc_x) + Number(this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].xlcc_y) <= Number(tzX) + Number(tzY) + 100) {
          this.axios.axiosPost('UpdateCncData', {
            'id': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].id,
            'cxmc': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].cxmc,
            'tdgd': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].tdgd,
            'ygsj': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].ygsj,
            'djxq': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].djxq,
            'zjfs': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].zjfs,
            'jgyd': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].jgyd,
            // 'djqr': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].djqr,
            // 'jcqj': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].jcqj,
            // 'dpdw': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].dpdw,
            // 'mcqj': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].mcqj,
            // 'cxycclsj': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].cxycclsj,
            'dbjz': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].dbjz,
            'zjbs': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].zjbs,
            'cnc': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].cnc,
            'cncsj': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].cncsj,
            'box': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].box,
            'xlcc_x': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].xlcc_x,
            'xlcc_y': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].xlcc_y,
            'xlcc_z': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].xlcc_z,
            'xlcc_bs': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].xlcc_bs,
            'xlcc_pb': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].xlcc_pb,
            'yjjg': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].yjjg,
            'gjsl': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].gjsl,
            'blps': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].blps,
            'bcry': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].bcry,
            'bzhu': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].bzhu,
            'zjzgs': this.editCache[key + (this.curPage - 1) * this.pageSize].data[key + (this.curPage - 1) * this.pageSize].zjzgs
          })
            .then((data) => {
              if (data['result'] === 'ok') {
                this.allUnion();
              }
            })
            .catch((err) => {
              console.log(err);
            })
        } else {
          console.log(tzX, tzY);

          alert('填写尺寸不能大于图纸尺寸+100');
          this.editCache[key].edit = true;
          this.editCache[key].isdel = true;
        }
      }
    }
  }

  // 程序名称排序
  sortCxmcASC() {
    let a;
    //  没有指定机台  则显示所有机台
    if (!this.CNCname || this.CNCname == "所有機台") {
      this.CNCname = "所有機台";
      a = "";
    } else {
      a = this.CNCname;
    }
    this.axios.axiosPost('QueryCncData', { 'order': 'order by cxmc ASC', 'unionorder': this.CNCdata, 'cnc': a, "status": this.statuswz, "banci": this.banBie, "riqi": this.time })
      .then((data) => {
        if (data['result'] === 'ok') {
          console.log(data)
          this.listOfData = data['order'];
          this.listOfDisplayData = [...this.listOfData];
          this.getPageList();
          for (let i = 0; i < this.listOfData.length; i++) {
            this.editCache[i] = { edit: false, data: this.listOfData };
          }
          console.log(this.editCache[0].data[0].factory)
          this.storage.setStorageData('result', this.listOfData);
        }
        console.log(data)
      })
      .catch((err) => {
        console.log(err);
      })
  }
  // 程序名称排序
  sortCxmcDESC() {
    let a;
    //  没有指定机台  则显示所有机台
    if (!this.CNCname || this.CNCname == "所有機台") {
      this.CNCname = "所有機台";
      a = "";
    } else {
      a = this.CNCname;
    }
    this.axios.axiosPost('QueryCncData', { 'order': 'order by cxmc DESC', 'unionorder': this.CNCdata, 'cnc': a, "status": this.statuswz, "banci": this.banBie, "riqi": this.time })
      .then((data) => {
        if (data['result'] === 'ok') {
          console.log(data)
          this.listOfData = data['order'];
          this.listOfDisplayData = [...this.listOfData];
          this.getPageList();
          for (let i = 0; i < this.listOfData.length; i++) {
            this.editCache[i] = { edit: false, data: this.listOfData };
          }
          console.log(this.editCache[0].data[0].factory)
          this.storage.setStorageData('result', this.listOfData);
        }
        console.log(data)
      })
      .catch((err) => {
        console.log(err);
      })
  }
  // 工联单号排序
  sortUnionorderASC() {
    let a;
    //  没有指定机台  则显示所有机台
    if (!this.CNCname || this.CNCname == "所有機台") {
      this.CNCname = "所有機台";
      a = "";
    } else {
      a = this.CNCname;
    }
    this.axios.axiosPost('QueryCncData', { 'order': 'order by union_order ASC', 'unionorder': this.CNCdata, 'cnc': a, "status": this.statuswz, "banci": this.banBie, "riqi": this.time })
      .then((data) => {
        if (data['result'] === 'ok') {
          console.log(data)
          this.listOfData = data['order'];
          this.listOfDisplayData = [...this.listOfData];
          this.getPageList();
          for (let i = 0; i < this.listOfData.length; i++) {
            this.editCache[i] = { edit: false, data: this.listOfData };
          }
          console.log(this.editCache[0].data[0].factory)
          this.storage.setStorageData('result', this.listOfData);
        }
        console.log(data)
      })
      .catch((err) => {
        console.log(err);
      })
  }
  // 工联单号排序
  sortUnionorderDESC() {
    let a;
    //  没有指定机台  则显示所有机台
    if (!this.CNCname || this.CNCname == "所有機台") {
      this.CNCname = "所有機台";
      a = "";
    } else {
      a = this.CNCname;
    }
    this.axios.axiosPost('QueryCncData', { 'order': 'order by union_order DESC', 'unionorder': this.CNCdata, 'cnc': a, "status": this.statuswz, "banci": this.banBie, "riqi": this.time })
      .then((data) => {
        if (data['result'] === 'ok') {
          console.log(data)
          this.listOfData = data['order'];
          this.listOfDisplayData = [...this.listOfData];
          this.getPageList();
          for (let i = 0; i < this.listOfData.length; i++) {
            this.editCache[i] = { edit: false, data: this.listOfData };
          }
          console.log(this.editCache[0].data[0].factory)
          this.storage.setStorageData('result', this.listOfData);
        }
        console.log(data)
      })
      .catch((err) => {
        console.log(err);
      })
  }

  // 零件名称排序
  sortLjmcASC() {
    let a;
    //  没有指定机台  则显示所有机台
    if (!this.CNCname || this.CNCname == "所有機台") {
      this.CNCname = "所有機台";
      a = "";
    } else {
      a = this.CNCname;
    }
    this.axios.axiosPost('QueryCncData', { 'order': 'order by ljmc ASC', 'unionorder': this.CNCdata, 'cnc': a, "status": this.statuswz, "banci": this.banBie, "riqi": this.time })
      .then((data) => {
        if (data['result'] === 'ok') {
          console.log(data)
          this.listOfData = data['order'];
          this.listOfDisplayData = [...this.listOfData];
          this.getPageList();
          for (let i = 0; i < this.listOfData.length; i++) {
            this.editCache[i] = { edit: false, data: this.listOfData };
          }
          this.storage.setStorageData('result', this.listOfData);
        }
        console.log(data)
      })
      .catch((err) => {
        console.log(err);
      })
  }
  // 零件名称排序
  sortLjmcDESC() {
    let a;
    //  没有指定机台  则显示所有机台
    if (!this.CNCname || this.CNCname == "所有機台") {
      this.CNCname = "所有機台";
      a = "";
    } else {
      a = this.CNCname;
    }
    this.axios.axiosPost('QueryCncData', { 'order': 'order by ljmc DESC', 'unionorder': this.CNCdata, 'cnc': a, "status": this.statuswz, "banci": this.banBie, "riqi": this.time })
      .then((data) => {
        if (data['result'] === 'ok') {
          console.log(data)
          this.listOfData = data['order'];
          this.listOfDisplayData = [...this.listOfData];
          this.getPageList();
          for (let i = 0; i < this.listOfData.length; i++) {
            this.editCache[i] = { edit: false, data: this.listOfData };
          }
          console.log(this.editCache[0].data[0].factory)
          this.storage.setStorageData('result', this.listOfData);
        }
        console.log(data)
      })
      .catch((err) => {
        console.log(err);
      })
  }

  // cnc机台排序
  sortCncASC() {
    let a;
    //  没有指定机台  则显示所有机台
    if (!this.CNCname || this.CNCname == "所有機台") {
      this.CNCname = "所有機台";
      a = "";
    } else {
      a = this.CNCname;
    }
    this.axios.axiosPost('QueryCncData', { 'order': 'order by cnc ASC', 'unionorder': this.CNCdata, "status": this.statuswz, 'cnc': a, "banci": this.banBie, "riqi": this.time })
      .then((data) => {
        if (data['result'] === 'ok') {
          console.log(data)
          this.listOfData = data['order'];
          this.listOfDisplayData = [...this.listOfData];
          this.getPageList();
          for (let i = 0; i < this.listOfData.length; i++) {
            this.editCache[i] = { edit: false, data: this.listOfData };
          }
          console.log(this.editCache[0].data[0].factory)
          this.storage.setStorageData('result', this.listOfData);
        }
        console.log(data)
      })
      .catch((err) => {
        console.log(err);
      })
  }
  // cnc机台排序
  sortCncDESC() {
    let a;
    //  没有指定机台  则显示所有机台
    if (!this.CNCname || this.CNCname == "所有機台") {
      this.CNCname = "所有機台";
      a = "";
    } else {
      a = this.CNCname;
    }
    // debugger
    this.axios.axiosPost('QueryCncData', { 'order': 'order by cnc DESC', 'unionorder': this.CNCdata, "status": this.statuswz, 'cnc': a, "banci": this.banBie, "riqi": this.time })
      .then((data) => {
        if (data['result'] === 'ok') {
          console.log(data)
          this.listOfData = data['order'];
          this.listOfDisplayData = [...this.listOfData];
          this.getPageList();
          for (let i = 0; i < this.listOfData.length; i++) {
            this.editCache[i] = { edit: false, data: this.listOfData };
          }
          console.log(this.editCache[0].data[0].factory)
          this.storage.setStorageData('result', this.listOfData);
        }
        console.log(data)
      })
      .catch((err) => {
        console.log(err);
      })
  }
  onegotwo(item) {
    if (Number(item.gjsl) > 1 && item.gjsl) {
      console.log(item)
      this.fdnumber = Number(item.gjsl) - 1;
      // this.fdbox = item.box;
      this.fdcnc = item.cnc;
      this.fdid = item.id
      this.fdmaxnumber = item.gjsl;
      this.isVisible2 = true;
    }
  }
  handleOk2() {
    // console.log(this.fdbox)
    console.log(this.fdcnc)
    console.log(this.fdnumber)
    if (this.fdnumber == 0) {
      alert("工件數量为0")
    } else if (this.fdnumber < this.fdmaxnumber) {
      this.axios.axiosPost("AddCncDataEx", { id: this.fdid, gjsl: this.fdnumber, cnc: this.fdcnc }).then((data) => {
        console.log(data)
        this.isVisible2 = false;
        this.allUnion();
      })
    } else {
      alert("工件數量不足")
    }

    // this.isVisible2 = false;
  }
  handleCancel2() {
    this.isVisible2 = false;
  }
  // 点击送出
  send(a) {
    if (!a.timestamp) {
      console.log(this.statuswz);
      this.readybye = a;
      this.isSendVisible = true;
    } else {
      alert("該工件未停止計時")
    }

  }
  // 确认送出
  sendOk() {
    if (this.statuswz == 1) {
      if (this.readybye['cxmc'] !== '' && this.readybye['tdgd'] !== '' && this.readybye['ygsj'] !== '' && this.readybye['djxq'] !== '' && this.readybye['zjfs'] !== '' && this.readybye['jgyd'] !== ''
        && this.readybye['xlcc_x'] !== '' && this.readybye['xlcc_y'] !== '' && this.readybye['xlcc_z'] !== '' && this.readybye['xlcc_bs'] !== '' && this.readybye['yjjg'] !== '' && this.readybye['blps'] !== '' && this.readybye['bcry'] !== '') {
        if (this.readybye['cnc']) {
          this.axios.axiosPost("UpdateUnionOrder2", { 'unionorder': this.readybye['union_order'], "name1": "stage", "newValue1": 2, "stageValue": 1, id: this.readybye["id"] }).then((data) => {
            console.log(data, "工单状态修改成功了,增加了加工的状态")
          })
          this.axios.axiosPost('UpdateWorkOrder', { "unionorder": this.readybye['union_order'], "workorder": this.readybye["ljmc"], id: this.readybye["id"], 'status': 2, })
            .then((data) => {
              console.log(data)
              if (data['result'] === 'ok') {
                this.axios.axiosPost('QueryWorkOrder', { 'unionorder': this.readybye['union_order'], "type": 1, "status": 1 }).then((data) => {
                  console.log(data);
                  if (data["result"] == "ok") {
                    if (data["order"] == undefined || data["order"].length <= 0) {
                      // this.axios.axiosPost("UpdateUnionOrder2", { 'unionorder': this.unionorder, "name1": "stage", "newValue1": 1, "stageValue": 0, "newValue12": 2, "stageValue2": 1 }).then((data) => {
                      console.log(data, "工单状态修改成功了,取消了当前工单状态")
                      this.allUnion();
                      this.isSendVisible = false;
                      // })
                    } else {
                      this.allUnion();
                      this.isSendVisible = false;
                    }
                  }


                })
              }
            })
            .catch((err) => {
              console.log(err);
            })

        } else {
          alert("该工件未指派机台")
          this.isSendVisible = false;
        }
      } else {
        alert('排工單信息未填完整');
        this.isSendVisible = false;
      }
    } else if (this.statuswz == 2) {
      if (this.readybye['dbjz'] !== '' && this.readybye['zjbs'] !== '' && this.readybye['cncsj'] !== '' && this.readybye['box'] !== '') {
        if (this.readybye['box']) {
          console.log("重点")
          if (this.readybye["bom_remark"]) {
            this.axios.axiosPost("UpdateUnionOrder2", { 'unionorder': this.readybye['union_order'], "name1": "stage", "newValue1": 3, "stageValue": 1 }).then((data) => {
              console.log(data, "工单状态修改成功了,增加了品鉴的状态")
            })
            this.axios.axiosPost('UpdateWorkOrder', {
              'unionorder': this.readybye['union_order'], 'workorder': this.readybye['ljmc'], id: this.readybye['id'],
              'status': 3, "check_date": ""
            })
              .then((data) => {
                console.log(data)
                if (data['result'] === 'ok') {
                  this.axios.axiosPost("QueryWorkOrder", {
                    'unionorder': this.readybye['union_order'], "type": 1, "status": 2

                  }).then((data) => {
                    if (data["result"] == "ok") {
                      if (data["order"] == undefined || data["order"].length <= 0) {
                        this.axios.axiosPost("UpdateUnionOrder2", { 'unionorder': this.readybye['union_order'], "name1": "stage", "newValue1": 2, "stageValue": 0 }).then((data) => {
                          this.isSendVisible = false;
                          this.allUnion();
                          console.log("工单状态修改成功了,取消了加工的状态")

                        })
                      }
                    }
                  })
                  this.isSendVisible = false;
                  this.allUnion();
                }
              })
              .catch((err) => {
                console.log(err);
              })


          } else {
            this.axios.axiosPost("UpdateUnionOrder2", { 'unionorder': this.readybye['union_order'], "name1": "stage", "newValue1": 4, "stageValue": 1 }).then((data) => {
              console.log(data, "工单状态修改成功了,增加了品鉴的状态")
            })
            this.axios.axiosPost('UpdateWorkOrder', {
              'unionorder': this.readybye['union_order'], 'workorder': this.readybye['ljmc'], id: this.readybye['id'],
              'status': 4, "machine_end_date_2": ""
            }).then((data) => {
              console.log(data)
              if (data['result'] === 'ok') {
                this.axios.axiosPost("QueryWorkOrder", { 'unionorder': this.readybye['union_order'], "type": 1, "status": 2 }).then((data) => {
                  if (data["result"] == "ok") {
                    if (data["order"] == undefined || data["order"].length <= 0) {
                      this.axios.axiosPost("UpdateUnionOrder2", { 'unionorder': this.readybye['union_order'], "name1": "stage", "newValue1": 2, "stageValue": 0 }).then((data) => {
                        console.log(data, "工单状态修改成功了,取消了加工的状态")
                        this.isSendVisible = false;
                        this.allUnion();
                      })
                    }
                  }

                  console.log(data, "工件状态修改成功了,工件状态修改为4")

                  this.isSendVisible = false;
                  this.allUnion();

                })

              }
            })
              .catch((err) => {
                console.log(err);
              })
          }
        } else {
          alert("未指定箱號")
        }
      } else {
        alert('排工單信息未填完整');
        this.isSendOkLoading = true;
        this.isSendVisible = false;
        this.isSendOkLoading = false;
      }
    } else {
      alert("未檢測到來自哪道工序的操作")
    }
  }
  // 取消送出
  handleSendCancel() {
    this.isSendVisible = false;
  }

  //点击退回
  return(a) {
    if (!a.timestamp) {
      this.readybye = a;
      this.addOtherRemark = true;
      let index = a.remark.indexOf(this.storage.getStorageData('user').name)
      if (index === 0 && a['remark']) {
        this.RemarkValue = a.remark + '\n\n';
      } else {
        this.RemarkValue = this.storage.getStorageData('user').name + ' : \n\n' + a.remark;
      }
    } else {
      alert("該工件未停止計時")
    }
  }
  //取消退回;
  CancelRemark() {
    this.addOtherRemark = false;
  }
  // 确认退回
  RemarkOk() {
    console.log(this.statuswz);

    if (this.statuswz == 1) {
      console.log("1");

      console.log(this.readybye);
      this.axios.axiosPost("UpdateUnionOrder2", { 'unionorder': this.readybye.union_order, "name1": "stage", "newValue1": 0, "stageValue": 1 }).then((data) => {
        console.log(data, "工单状态修改成功了,增加了编程的状态")
      })
      this.axios.axiosPost("UpdateUnionOrder2", { 'unionorder': this.readybye.union_order, "name1": "zuzhuang_endtime", "newValue1": "", "name2": "ercijg_endtime", "newValue2": "", "name3": "jiagong_endtime", "newValue3": "", "name4": "biancheng_endtime", "newValue4": "", "name5": "sheji_endtime", "newValue5": "" }).then((data) => {
        console.log(data, "取消组装,二次加工,加工，编程,设计时间栏位,")
      })
      this.axios.axiosPost('UpdateWorkOrder', {
        'unionorder': this.readybye.union_order, 'remark': this.RemarkValue, 'status': 0, "tuidan": 1
      })
        .then((data) => {
          console.log(data)
          if (data['result'] === 'ok') {
            this.axios.axiosPost('QueryWorkOrder', { 'unionorder': this.readybye.union_order, "type": 1, "status": 1 }).then((data) => {
              console.log(data["order"].length)
              if (data["order"].length <= 0) {
                this.axios.axiosPost("UpdateUnionOrder2", { 'unionorder': this.readybye.union_order, "name1": "stage", "newValue1": 0, "stageValue": 1, "newValue12": 1, "stageValue2": 0 }).then((data) => {
                  console.log(data, "工单状态修改成功了,取消了当前工单状态")
                  this.allUnion();
                  this.addOtherRemark = false;

                })
              } else {
                this.allUnion();
                this.addOtherRemark = false;

              }
            })
          }
        })
        .catch((err) => {
          console.log(err);
        })
      // this.axios.axiosPost("ResetUnionOrder", { unionorder: this.readybye['union_order'] }).then((data) => {
      //   console.log(data);

      //   if (data['result'] == "ok") {
      //     this.addOtherRemark = false;

      //     this.allUnion();
      //   }
      // })
    } else {
      console.log("2");

      if (this.RemarkValue.length != 0) {
        this.addOtherRemark = false;
        let content = '';
        content = this.RemarkValue;//姓名+内容
        console.log(content)
        this.axios.axiosPost("UpdateUnionOrder2", { 'unionorder': this.readybye.union_order, "name1": "stage", "newValue1": 1, "stageValue": 1 }).then((data) => {
          console.log(data, "工单状态修改成功了,增加了编程的状态")
        })
        this.axios.axiosPost("UpdateUnionOrder2", { 'unionorder': this.readybye.union_order, "name1": "zuzhuang_endtime", "newValue1": "", "name2": "ercijg_endtime", "newValue2": "", "name3": "jiagong_endtime", "newValue3": "", "name4": "biancheng_endtime", "newValue4": "" }).then((data) => {
          console.log(data, "取消组装,二次加工,加工，编程时间栏位,")
        })
        this.axios.axiosPost('UpdateWorkOrder', {
          'unionorder': this.readybye.union_order, 'workorder': this.workerName, id: this.readybye["id"], 'remark': content, 'status': 1
        })
          .then((data) => {
            console.log(data)
            if (data['result'] === 'ok') {
              this.axios.axiosPost('QueryWorkOrder', { 'unionorder': this.readybye.union_order, "type": 1, "status": 2 }).then((data) => {
                console.log(data["order"].length)
                if (data["order"].length <= 0) {
                  this.axios.axiosPost("UpdateUnionOrder2", { 'unionorder': this.readybye.union_order, "name1": "stage", "newValue1": 1, "stageValue": 1, "newValue12": 2, "stageValue2": 0 }).then((data) => {
                    console.log(data, "工单状态修改成功了,取消了当前工单状态")
                    this.allUnion();
                    this.addOtherRemark = false;

                  })
                } else {
                  this.allUnion();
                  this.addOtherRemark = false;

                }
              })
            }
          })
          .catch((err) => {
            console.log(err);
          })
      } else {
        alert("請輸入退單備註")
      }
    }
  }
  downLoad2(infom) {
    console.log(infom);
    this.fileInfom2 = true;
    this.link = this.axios.domainTest1;
    console.log(this.link);

    if (infom.imagefile) {
      this.imglist = infom.imagefile.split(",");
    } else {
      this.imglist = [];
    }
  }
  CancelShow2() {
    this.fileInfom2 = false;
  }
  ShowOK2() {
    this.fileInfom2 = false;
  }
  show2() {
    console.log(this.CNCname);
    this.allUnion()
  }
}


